<% if current_user %>
<h1>Registered Users</h1>

<table cellspacing="10">
  <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Address (line 1)</th>
    <th>Address (line 2)</th>
    <th>City</th>
    <th>State</th>
    <th>Zip Code</th>
    <th>Is Driver</th>
    <th>Is Customer</th>
    <th>Is Admin</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @users.each do |user| %>
  <tr>
    <td><%= user.first_name %></td>
    <td><%= user.last_name %></td>
    <td><%= user.email %></td>
    <td><%= user.phone %></td>
    <td><%= user.addr1 %></td>
    <td><%= user.addr2 %></td>
    <td><%= user.city %></td>
    <td><%= user.state %></td>
    <td><%= user.zip %></td>
    <td><%= user.isdriver %></td>
    <td><%= user.iscustomer %></td>
    <td><%= user.isadmin %></td>
    <td><%= link_to 'Show', user %></td>
    <% if current_user.isadmin || (current_user && current_user.id == user.id) %>
      <td><%= link_to 'Edit', edit_user_path(user) %></td>
      <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
    <% end %>
  </tr>
<% end %>
</table>

<br />
<% if current_user.isadmin %>
  <%= link_to 'New User', new_user_path %>
<% end %>
<%= link_to 'Back', :back %>
<% else %>
<p>Error: You are not currently logged in.</p>
<p>If you would like to view current users, please <%= link_to "log in", log_in_path %>.<p>
<p>If you do not have an account, please <%= link_to "sign up", sign_up_path %><p>
<p>Or you can return to the <%= link_to "home page", root_url %>.<p
<% end %>
